<!DOCTYPE html>
<html lang="zh-cn">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <title>Python Scrapy框架Ubuntu 15.04下安装小记 - fangd123</title>
  <meta name="renderer" content="webkit" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>

<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />

<meta name="theme-color" content="#f8f5ec" />
<meta name="msapplication-navbutton-color" content="#f8f5ec">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="#f8f5ec">


<meta name="author" content="fangd123" /><meta name="description" content="我这人有个坏习惯，总是喜欢装最新的东西，殊不知最新的不一定是最稳定的，有时候会出现一些Error和Bug，另外，针对与桌面系统的Ubuntu" /><meta name="keywords" content="fangd123, 博客, 技术, 生活" />






<meta name="generator" content="Hugo 0.65.3 with theme even" />


<link rel="canonical" href="https://blog.fangd123.com/post/python-scarpy-ubuntu-install-log/" />
<link rel="apple-touch-icon" sizes="180x180" href="https://blog.fangd123.com/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="https://blog.fangd123.com/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="https://blog.fangd123.com/favicon-16x16.png">
<link rel="manifest" href="https://blog.fangd123.com/manifest.json">
<link rel="mask-icon" href="https://blog.fangd123.com/safari-pinned-tab.svg" color="#5bbad5">

<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
<link href="https://blog.fangd123.com/dist/even.c2a46f00.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.1.20/dist/jquery.fancybox.min.css" integrity="sha256-7TyXnr2YU040zfSP+rEcz29ggW4j56/ujTPwjMzyqFY=" crossorigin="anonymous">


<meta property="og:title" content="Python Scrapy框架Ubuntu 15.04下安装小记" />
<meta property="og:description" content="我这人有个坏习惯，总是喜欢装最新的东西，殊不知最新的不一定是最稳定的，有时候会出现一些Error和Bug，另外，针对与桌面系统的Ubuntu" />
<meta property="og:type" content="article" />
<meta property="og:url" content="https://blog.fangd123.com/post/python-scarpy-ubuntu-install-log/" />
<meta property="article:published_time" content="2015-09-28T11:51:02-05:00" />
<meta property="article:modified_time" content="2015-09-28T11:51:02-05:00" />
<meta itemprop="name" content="Python Scrapy框架Ubuntu 15.04下安装小记">
<meta itemprop="description" content="我这人有个坏习惯，总是喜欢装最新的东西，殊不知最新的不一定是最稳定的，有时候会出现一些Error和Bug，另外，针对与桌面系统的Ubuntu">
<meta itemprop="datePublished" content="2015-09-28T11:51:02-05:00" />
<meta itemprop="dateModified" content="2015-09-28T11:51:02-05:00" />
<meta itemprop="wordCount" content="755">



<meta itemprop="keywords" content="" /><meta name="twitter:card" content="summary"/>
<meta name="twitter:title" content="Python Scrapy框架Ubuntu 15.04下安装小记"/>
<meta name="twitter:description" content="我这人有个坏习惯，总是喜欢装最新的东西，殊不知最新的不一定是最稳定的，有时候会出现一些Error和Bug，另外，针对与桌面系统的Ubuntu"/>

<!--[if lte IE 9]>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/classlist/1.1.20170427/classList.min.js"></script>
<![endif]-->

<!--[if lt IE 9]>
  <script src="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script>
<![endif]-->

</head>
<body>
  <div id="mobile-navbar" class="mobile-navbar">
  <div class="mobile-header-logo">
    <a href="https://blog.fangd123.com/" class="logo">fangd123</a>
  </div>
  <div class="mobile-navbar-icon">
    <span></span>
    <span></span>
    <span></span>
  </div>
</div>
<nav id="mobile-menu" class="mobile-menu slideout-menu">
  <ul class="mobile-menu-list">
    <a href="https://blog.fangd123.com/">
        <li class="mobile-menu-item">主页</li>
      </a><a href="https://blog.fangd123.com/categories/%E6%8A%80%E6%9C%AF">
        <li class="mobile-menu-item">技术</li>
      </a><a href="https://blog.fangd123.com/categories/%E7%94%9F%E6%B4%BB">
        <li class="mobile-menu-item">生活</li>
      </a><a href="https://blog.fangd123.com/post/">
        <li class="mobile-menu-item">归档</li>
      </a><a href="https://blog.fangd123.com/tags/">
        <li class="mobile-menu-item">标签</li>
      </a><a href="https://blog.fangd123.com/categories/">
        <li class="mobile-menu-item">分类</li>
      </a>
  </ul>
</nav>
  <div class="container" id="mobile-panel">
    <header id="header" class="header">
        <div class="logo-wrapper">
  <a href="https://blog.fangd123.com/" class="logo">fangd123</a>
</div>

<nav class="site-navbar">
  <ul id="menu" class="menu">
    <li class="menu-item">
        <a class="menu-item-link" href="https://blog.fangd123.com/">主页</a>
      </li><li class="menu-item">
        <a class="menu-item-link" href="https://blog.fangd123.com/categories/%E6%8A%80%E6%9C%AF">技术</a>
      </li><li class="menu-item">
        <a class="menu-item-link" href="https://blog.fangd123.com/categories/%E7%94%9F%E6%B4%BB">生活</a>
      </li><li class="menu-item">
        <a class="menu-item-link" href="https://blog.fangd123.com/post/">归档</a>
      </li><li class="menu-item">
        <a class="menu-item-link" href="https://blog.fangd123.com/tags/">标签</a>
      </li><li class="menu-item">
        <a class="menu-item-link" href="https://blog.fangd123.com/categories/">分类</a>
      </li>
  </ul>
</nav>
    </header>

    <main id="main" class="main">
      <div class="content-wrapper">
        <div id="content" class="content">
          <article class="post">
    
    <header class="post-header">
      <h1 class="post-title">Python Scrapy框架Ubuntu 15.04下安装小记</h1>

      <div class="post-meta">
        <span class="post-time"> 2015-09-28 </span>
        <div class="post-category">
            <a href="https://blog.fangd123.com/categories/%E7%94%9F%E6%B4%BB/"> 生活 </a>
            </div>
          <span class="more-meta"> 约 755 字 </span>
          <span class="more-meta"> 预计阅读 2 分钟 </span>
        <span id="busuanzi_container_page_pv" class="more-meta"> <span id="busuanzi_value_page_pv"><img src="https://blog.fangd123.com/img/spinner.svg" alt="spinner.svg"/></span> 次阅读 </span>
      </div>
    </header>

    <div class="post-toc" id="post-toc">
  <h2 class="post-toc-title">文章目录</h2>
  <div class="post-toc-content always-active">
    <nav id="TableOfContents"></nav>
  </div>
</div>
    <div class="post-content">
      <p>我这人有个坏习惯，总是喜欢装最新的东西，殊不知最新的不一定是最稳定的，有时候会出现一些Error和Bug，另外，针对与桌面系统的Ubuntu和针对与服务器的CentOS比起来，组件的齐全度上确实还是差了一些，非常多的组件需要自己安装。想我之前用CenOS7的时候直接用<code>pip install scrapy</code>就把Scrapy安装好了，但是在Ubuntu下边，光是安装各种包就花费了不少的时间。不过没办法，谁让Ubuntu是最受欢迎的Linux操作系统呢。</p>
<p>安装过程我这里就不再赘述了，一般是按照官网推荐的使用<code>pip install</code>安装，Ubuntu软件库中自带的Scrapy因为版本比较老了没有更新，官方不建议安装，如果确实享用<code>apt-get install</code>安装的话，官网也有相对应的教程，照着做就是了。</p>
<p>在安装的过程中，会出现很多很多很多（没错，非常多）错误，究其原因，Ubuntu许多开发相关的库都没有安装，需要我们手动进行。不过还好，错误提示里边一般都会写明出现了什么错误，将错误在谷歌中搜索即可。</p>
<ul>
<li>
<p>有时候是找不到<code>.h</code>头文件，这个时候需要谷歌对应的头文件，寻找对应的安装包安装。</p>
</li>
<li>
<p>也有这样的错误</p>
</li>
</ul>
<blockquote>
<p>UnicodeDecodeError: &lsquo;ascii&rsquo; codec can&rsquo;t decode byte 0xc3 in position 0: ordinal not in range(128)</p>
</blockquote>
<p>这个就需要对于python的配置文件进行修改，具体修改方法如下：</p>
<p>找到Python安装目录\Lib下的 mimetypes.py 文件，找到大概256行（你可以用Notepad++的搜索功能）的<code>default_encoding = sys.getdefaultencoding()</code>在前边增加如下代码：</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span><span class="lnt">4
</span></code></pre></td>
<td class="lntd">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="k">if</span> <span class="n">sys</span><span class="o">.</span><span class="n">getdefaultencoding</span><span class="p">()</span> <span class="o">!=</span> <span class="s1">&#39;gbk&#39;</span><span class="p">:</span>
	<span class="nb">reload</span><span class="p">(</span><span class="n">sys</span><span class="p">)</span>
	<span class="n">sys</span><span class="o">.</span><span class="n">setdefaultencoding</span><span class="p">(</span><span class="s1">&#39;gbk&#39;</span><span class="p">)</span>
<span class="n">default_encoding</span> <span class="o">=</span> <span class="n">sys</span><span class="o">.</span><span class="n">getdefaultencoding</span><span class="p">()</span>
</code></pre></td></tr></table>
</div>
</div><p><em>感谢<a href="http://blog.csdn.net/hugleecool/article/details/17996993#">hugleecool的博客</a>提供解决方案</em></p>
<p>在经过一番折腾之后，最后总算是顺利安装上去了，没有报错。说实话，配置都这么花费时间我觉得真心应该像Laravel学习直接给一个虚拟机镜像，不把时间花费在配置上，集中精力进行开发。</p>

    </div>

    <div class="post-copyright">
  <p class="copyright-item">
    <span class="item-title">文章作者</span>
    <span class="item-content">fangd123</span>
  </p>
  <p class="copyright-item">
    <span class="item-title">上次更新</span>
    <span class="item-content">
        2015-09-28
        
    </span>
  </p>
  
  
</div>
<footer class="post-footer">
      
      <nav class="post-nav">
        <a class="prev" href="https://blog.fangd123.com/post/master-degree-study-plan/">
            <i class="iconfont icon-left"></i>
            <span class="prev-text nav-default">研究生阶段学习计划</span>
            <span class="prev-text nav-mobile">上一篇</span>
          </a>
        <a class="next" href="https://blog.fangd123.com/post/%E6%9C%9D%E5%A4%95%E4%B9%A6%E5%90%A7%E5%8D%81%E6%9C%88%E5%98%89%E5%AE%BE%E4%B8%BB%E9%A2%98%E5%88%86%E4%BA%AB%E6%8F%90%E7%BA%B2/">
            <span class="next-text nav-default">朝夕书吧十月嘉宾主题分享提纲</span>
            <span class="next-text nav-mobile">下一篇</span>
            <i class="iconfont icon-right"></i>
          </a>
      </nav>
    </footer>
  </article>
        </div>
        <div id="gitalk-container"></div>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.css" crossorigin="anonymous">
    <script src="https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.js" crossorigin="anonymous"></script>
    <script type="text/javascript">
      var gitalk = new Gitalk({
        id: '2015-09-28 11:51:02 -0500 -0500',
        title: 'Python Scrapy框架Ubuntu 15.04下安装小记',
        clientID: 'e7701fe6c1c3f1819cca',
        clientSecret: '0279597bf6b736da28a66ac649db4851303b9d95',
        repo: 'fangd123.github.io',
        owner: 'fangd123',
        admin: ['fangd123'],
        body: decodeURI(location.href)
      });
      gitalk.render('gitalk-container');
    </script>
    <noscript>Please enable JavaScript to view the <a href="https://github.com/gitalk/gitalk">comments powered by gitalk.</a></noscript>

  

  

      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="social-links">
      <a href="mailto:fangd123@gmail.com" class="iconfont icon-email" title="email"></a>
      <a href="https://github.com/fangd123" class="iconfont icon-github" title="github"></a>
      <a href="https://weibo.com/p/1005051761690660/" class="iconfont icon-weibo" title="weibo"></a>
      <a href="https://www.zhihu.com/people/fang-wen-da" class="iconfont icon-zhihu" title="zhihu"></a>
      <a href="http://localhost:1313" class="iconfont icon-gitlab" title="gitlab"></a>
      <a href="http://localhost:1313" class="iconfont icon-bilibili" title="bilibili"></a>
  <a href="https://blog.fangd123.com/index.xml" type="application/rss+xml" class="iconfont icon-rss" title="rss"></a>
</div>

<div class="copyright">
  <span class="power-by">
    由 <a class="hexo-link" href="https://gohugo.io">Hugo</a> 强力驱动
  </span>
  <span class="division">|</span>
  <span class="theme-info">
    主题 - 
    <a class="theme-link" href="https://github.com/olOwOlo/hugo-theme-even">Even</a>
  </span>

  <div class="busuanzi-footer">
    <span id="busuanzi_container_site_pv"> 本站总访问量 <span id="busuanzi_value_site_pv"><img src="https://blog.fangd123.com/img/spinner.svg" alt="spinner.svg"/></span> 次 </span>
      <span class="division">|</span>
    <span id="busuanzi_container_site_uv"> 本站总访客数 <span id="busuanzi_value_site_uv"><img src="https://blog.fangd123.com/img/spinner.svg" alt="spinner.svg"/></span> 人 </span>
  </div>

  <span class="copyright-year">
    &copy; 
    2014 - 
    2020
    <span class="heart">
      <i class="iconfont icon-heart"></i>
    </span>
    <span class="author">fangd123</span>
  </span>
</div>
    </footer>

    <div class="back-to-top" id="back-to-top">
      <i class="iconfont icon-up"></i>
    </div>
  </div>
  
  <script src="https://cdn.jsdelivr.net/npm/jquery@3.2.1/dist/jquery.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
  <script src="https://cdn.jsdelivr.net/npm/slideout@1.0.1/dist/slideout.min.js" integrity="sha256-t+zJ/g8/KXIJMjSVQdnibt4dlaDxc9zXr/9oNPeWqdg=" crossorigin="anonymous"></script>
  <script src="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.1.20/dist/jquery.fancybox.min.js" integrity="sha256-XVLffZaxoWfGUEbdzuLi7pwaUJv1cecsQJQqGLe7axY=" crossorigin="anonymous"></script>
<script type="text/javascript" src="https://blog.fangd123.com/dist/even.26188efa.min.js"></script>








</body>
</html>
